#include <stdio.h>

class Rational
{
private:
	int p; // numerator
	int q; // denominator

	int getDivider();
	void Reduse();


public:
	Rational(int p, int q=1);
	
	Rational(const Rational& rat);	

	int getP() const;
	int getQ() const;

	Rational& operator+=(const Rational& rat);
	Rational& operator-=(const Rational& rat);
	Rational& operator/=(const Rational& rat);
	Rational operator*=(const Rational& rat);
	
	operator double();
	
	Rational operator++();
	Rational operator++(int);
	Rational operator--();
	Rational operator--(int);
};
	



Rational operator+(const Rational& rat1, const Rational& rat2);
Rational operator-(const Rational& rat1, const Rational& rat2);
Rational operator/(const Rational& rat1, const Rational& rat2);
Rational operator*(const Rational& rat1, const Rational& rat2);
bool operator==(const Rational& rat1, const Rational& rat2);
bool operator!=(const Rational& rat1, const Rational& rat2);
bool operator>(const Rational& rat1, const Rational& rat2);
bool operator<(const Rational& rat1, const Rational& rat2);
bool operator>=(const Rational& rat1, const Rational& rat2);
bool operator<=(const Rational& rat1, const Rational& rat2);
